package cn.com.myspring.framework.aop.aspect;

import java.lang.reflect.Method;

import cn.com.myspring.framework.aop.intercept.MYMethodInterceptor;
import cn.com.myspring.framework.aop.intercept.MYMethodInvocation;

public class MYAfterThrowingAdviceInterceptor extends MYAbstractAspectAdvice implements MYAdvice, MYMethodInterceptor {

    private String throwingName;

    public MYAfterThrowingAdviceInterceptor(Method aspectMethod, Object aspectTarget) {
        super(aspectMethod, aspectTarget);
    }

    @Override
    public Object invoke(MYMethodInvocation mi) throws Throwable {
        try {
            // 执行原有方法
            return mi.proceed();
        } catch (Throwable e) {
            // 调用异常通知
            invokeAdviceMethod(mi, null, e.getCause());
            throw e;
        }
    }

    public void setThrowName(String throwName) {
        this.throwingName = throwName;
    }
}
